<?php

namespace JLPay\Models\Trans\Dto;

/**
 * 优惠券信息DTO
 * 
 * @author liaochangyi
 * @since 2025-01-25
 */
class CouponInfoDto
{
    protected ?string $promotionId = null;  // 券ID
    protected ?string $name = null;  // 优惠名称
    protected ?string $scope = null;  // 优惠范围
    protected ?string $type = null;  // 优惠类型
    protected ?string $amount = null;  // 优惠券面额
    protected ?string $activityId = null;  // 活动ID
    protected ?string $wxpayContribute = null;  // 微信出资
    protected ?string $merchantContribute = null;  // 商户出资
    protected ?string $id = null;  // 支付宝券ID
    protected ?string $otherContribute = null;  // 其他出资金额
    protected ?string $memo = null;  // 备注信息
    protected ?string $templateId = null;  // 券模板ID
    protected ?string $otherContributeDetail = null;  // 优惠券的其他出资方明细
    protected ?string $purchaseBuyerContribute = null;  // 买家出资
    protected ?string $purchaseMerchantContribute = null;  // 商户出资
    protected ?string $purchaseAntContribute = null;  // 内部出资
    protected ?string $spnsrId = null;  // 出资方
    protected ?string $offstAmt = null;  // 优惠金额
    protected ?string $desc = null;  // 项目简称
    protected ?string $addnInfo = null;  // 附加信息
    protected ?string $issuerId = null;  // 项目发行方

    /**
     * 构造函数
     *
     * @param array|null $couponDict 优惠券信息字典
     */
    public function __construct(?array $couponDict = null)
    {
        if ($couponDict) {
            $this->promotionId = $couponDict['promotion_id'] ?? null;
            $this->name = $couponDict['name'] ?? null;
            $this->scope = $couponDict['scope'] ?? null;
            $this->type = $couponDict['type'] ?? null;
            $this->amount = $couponDict['amount'] ?? null;
            $this->activityId = $couponDict['activity_id'] ?? null;
            $this->wxpayContribute = $couponDict['wxpay_contribute'] ?? null;
            $this->merchantContribute = $couponDict['merchant_contribute'] ?? null;
            $this->id = $couponDict['id'] ?? null;
            $this->otherContribute = $couponDict['other_contribute'] ?? null;
            $this->memo = $couponDict['memo'] ?? null;
            $this->templateId = $couponDict['template_id'] ?? null;
            $this->otherContributeDetail = $couponDict['other_contribute_detail'] ?? null;
            $this->purchaseBuyerContribute = $couponDict['purchase_buyer_contribute'] ?? null;
            $this->purchaseMerchantContribute = $couponDict['purchase_merchant_contribute'] ?? null;
            $this->purchaseAntContribute = $couponDict['purchase_ant_contribute'] ?? null;
            $this->spnsrId = $couponDict['spnsr_id'] ?? null;
            $this->offstAmt = $couponDict['offst_amt'] ?? null;
            $this->desc = $couponDict['desc'] ?? null;
            $this->addnInfo = $couponDict['addn_info'] ?? null;
            $this->issuerId = $couponDict['issuer_id'] ?? null;
        }
    }

    /**
     * 获取券ID
     *
     * @return string|null
     */
    public function getPromotionId(): ?string
    {
        return $this->promotionId;
    }

    /**
     * 设置券ID
     *
     * @param string|null $promotionId
     * @return self
     */
    public function setPromotionId(?string $promotionId): self
    {
        $this->promotionId = $promotionId;
        return $this;
    }

    /**
     * 获取优惠名称
     *
     * @return string|null
     */
    public function getName(): ?string
    {
        return $this->name;
    }

    /**
     * 设置优惠名称
     *
     * @param string|null $name
     * @return self
     */
    public function setName(?string $name): self
    {
        $this->name = $name;
        return $this;
    }

    /**
     * 获取优惠券面额
     *
     * @return string|null
     */
    public function getAmount(): ?string
    {
        return $this->amount;
    }

    /**
     * 设置优惠券面额
     *
     * @param string|null $amount
     * @return self
     */
    public function setAmount(?string $amount): self
    {
        $this->amount = $amount;
        return $this;
    }

    /**
     * 获取支付宝券ID
     *
     * @return string|null
     */
    public function getId(): ?string
    {
        return $this->id;
    }

    /**
     * 设置支付宝券ID
     *
     * @param string|null $id
     * @return self
     */
    public function setId(?string $id): self
    {
        $this->id = $id;
        return $this;
    }

    /**
     * 转换为数组格式
     *
     * @return array
     */
    public function toArray(): array
    {
        return [
            'promotion_id' => $this->promotionId,
            'name' => $this->name,
            'scope' => $this->scope,
            'type' => $this->type,
            'amount' => $this->amount,
            'activity_id' => $this->activityId,
            'wxpay_contribute' => $this->wxpayContribute,
            'merchant_contribute' => $this->merchantContribute,
            'id' => $this->id,
            'other_contribute' => $this->otherContribute,
            'memo' => $this->memo,
            'template_id' => $this->templateId,
            'other_contribute_detail' => $this->otherContributeDetail,
            'purchase_buyer_contribute' => $this->purchaseBuyerContribute,
            'purchase_merchant_contribute' => $this->purchaseMerchantContribute,
            'purchase_ant_contribute' => $this->purchaseAntContribute,
            'spnsr_id' => $this->spnsrId,
            'offst_amt' => $this->offstAmt,
            'desc' => $this->desc,
            'addn_info' => $this->addnInfo,
            'issuer_id' => $this->issuerId
        ];
    }
} 